﻿using System.Data;
using Microsoft.ApplicationBlocks.Data;
using eCommerce.core.Helpers;

namespace eCommerce.core.AdminMenu
{
    public class AdminMenuDAL
    {
        private static readonly string Conn = Utils.GetMainConnectionString();
        
        public static int AdminMenu_GetStatistics(int status)
        {
            return (int) SqlHelper.ExecuteScalar(Conn, "AdminMenu_GetStatistics", status);
        }

        public static int AdminMenu_Create(AdminMenuObject o)
        {
            return (int) SqlHelper.ExecuteScalar(Conn, "AdminMenu_Create", o.ParentId, o.Name, o.CtrlKey, o.CtrlSource, o.Params, o.Priority, o.Status);
        }

        public static void AdminMenu_Update(AdminMenuObject o)
        {
            SqlHelper.ExecuteNonQuery(Conn, "AdminMenu_Update", o.AdminMenuId, o.ParentId, o.Name, o.CtrlKey, o.CtrlSource, o.Params, o.Priority, o.Status);
        }

        public static void AdminMenu_Delete(int adminMenuId)
        {
            SqlHelper.ExecuteNonQuery(Conn, "AdminMenu_Delete", adminMenuId);
        }

        public static IDataReader AdminMenu_GetById(int id)
        {
            return SqlHelper.ExecuteReader(Conn, "AdminMenu_GetById", id);
        }

        public static IDataReader AdminMenu_GetByParentId(int parentId)
        {
            return SqlHelper.ExecuteReader(Conn, "AdminMenu_GetByParentId", parentId);
        }

        public static IDataReader AdminMenu_GetAllByStatusAndUserId(int status, int userId)
        {
            return SqlHelper.ExecuteReader(Conn, "AdminMenu_GetAllByStatusAndUserId", status, userId);
        }
    }
}